package xhwl.insurance.customView;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import xhwl.insurance.R;


public class PopSelectPic extends PopupWindow {

	private Activity mActivity;
	public PopSelectPic(Activity activity, View parent) {
		mActivity=activity;
		View view = View.inflate(mActivity, R.layout.libwidget_select_pic_popupwindow, null);
		view.startAnimation(AnimationUtils.loadAnimation(mActivity,
				R.anim.fade_ins));
		LinearLayout ll_popup = (LinearLayout) view
				.findViewById(R.id.ll_popup);
		ll_popup.startAnimation(AnimationUtils.loadAnimation(mActivity,
				R.anim.push_bottom_in_2));

		setWidth(LayoutParams.MATCH_PARENT);
		setHeight(LayoutParams.MATCH_PARENT);
		setFocusable(true);
		setOutsideTouchable(true);
		setContentView(view);
		showAtLocation(parent, Gravity.BOTTOM, 0, 0);
		update();

		Button bt1 = (Button) view
				.findViewById(R.id.item_popupwindows_camera);
		Button bt2 = (Button) view
				.findViewById(R.id.item_popupwindows_Photo);
		Button bt3 = (Button) view
				.findViewById(R.id.item_popupwindows_cancel);
		bt1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				if(listener!=null){
					listener.onTakePhotoClick();
				}
				dismiss();
			}
		});
		bt2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				if(listener!=null){
					listener.onSelectPicClick();
				}
				dismiss();
			}
		});
		bt3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				dismiss();
			}
		});

	}
	public static interface PopSelectBtnClickListener{
		void onTakePhotoClick();
//		void onCancleClick();
		void onSelectPicClick();
	}
	public void setCallBack(PopSelectBtnClickListener listener){
		this.listener=listener;
	}
	private PopSelectBtnClickListener listener;
}
